#include "Producer.hpp"
#include "Thread.hpp"
#include "TaskQueue.hpp"

#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

#include <iostream>

using std::cout;
using std::endl;

namespace wd{

Producer::Producer(TaskQueue & taskque)
:_taskque(taskque){
    
}

void Producer::run(){
    srand(time(nullptr));
    for(int i = 0; i< 4; ++i){
        int num = rand() % 100;
        _taskque.push(num);
        pthread_t pthid = pthread_self(); 
        printf("线程id:%ld, 生产商品 %d \n",pthid % 10,num);
        sleep(3);
    }
}


}

